<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>邻助社区</title>
    <link rel="stylesheet" href="/news/front/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="front/css/public.css" media="all" />
    <link rel="stylesheet" href="css/public.css" media="all" />
    <link rel="stylesheet" href="css/index.css" media="all" />
    <script type="text/javascript" src="front/layui/layui.js"></script>
</head>
<body>
<!--导航栏-->
<div class='layui-bg-red' style='width: 100%'>
    <ul class='layui-nav nav_left' lay-filter=''>
        <li class='layui-nav-item'><a href='/news'>首页</a></li>
        <li class='layui-nav-item '>
            <a href='newslist.html?categoryId=1'>社区新闻</a>
        </li>
        <li class='layui-nav-item'><a href='newslist.html?categoryId=2'>社区帮助</a></li>
        <li class='layui-nav-item'><a href='newslist.html?categoryId=3'>社区风采</a></li>
        <li class='layui-nav-item'><a href='newslist.html?categoryId=4'>投稿专栏</a></li>
        <div class="search_container">
            <input class="layui-input search_article" type="text" placeholder="输入文章标题">
            <div class="result_container">
            </div>
        </div>
        <button type="button" class="layui-btn" style="margin-top: 15px" onclick="searchArticle()">搜索</button>
    </ul>
    <ul class='layui-nav nav_right' lay-filter=''>
        <li class='layui-nav-item tologin'>
            <a href='admin?method=toLogin'>登录</a>
        </li>
        <li class='layui-nav-item has-login'>
            <a href='javascript:;' class='username'></a>
            <dl class='layui-nav-child'> <!-- 二级菜单 -->
                <dd><a id='logout'>注销</a></dd>
                <dd><a href='postNewsDetail.html' id='post'>投稿</a></dd>
            </dl>
        </li>
    </ul>
</div>
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="news-list-title" >
                <dt><a href="#" class="category_name">邻助社区</a></dt>
            </div>
            <div class="ulbox">
                <ul>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>

<script type="text/javascript" src="/news/front/js/api.js"></script>
<script type="text/javascript" src="front/js/common.js"></script>
<script type="text/javascript" src="common/public.js"></script>
</html>

<script>
    var param = getRequest();
    layui.use(['layer','element','carousel'],function(){
        var $ = layui.jquery;
        getArticle(param.categoryId);

        function getArticle(categoryId){
            $.ajax({
                url:API_BASE_URL+'/article?method=getArticleListByCatelogyId&categoryId='+categoryId,
                method:"GET",
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                cache: false,
                success(res){
                    // 移除或注释这行动态设置分类名称的代码
                    // $(".category_name").text(res.data.categoryName)
                    if (res.code == 200){
                        for (let item in res.data.articleList){
                            let obj = res.data.articleList[''+item+''];
                            $(".ulbox").find("ul")
                                .append('<li >'+'<a href="content.html?id='+ obj.id +'">'+ obj.title +'</a>'+
                                    '<p>'+ obj.createTimeStr +'</p></li>');
                        }
                    }
                }
            })
        }
    })
</script>